/**
 * cateGory: 散点图
 */
import { xAxisCommon, yAxisCommon } from '../common-option'
import { mergeOption, setSeries } from '../util'
export default {
  name: 'scatter',
  option(param) {
    return mergeOption(param, {
      grid: {
        left: '40px',
        top: '35px',
        right: '80px',
        bottom: '35px'
      },
      xAxis: {
        type: 'value',
        min: 0,
        max: 1,
        splitNumber: 22,
        name: '',
        ...xAxisCommon,
        splitLine: {
          show: false
        }
      },
      yAxis: {
        type: 'value',
        min: 0,
        max: 1,
        splitNumber: 8,
        name: '',
        ...yAxisCommon,
        axisTick: {
          show: false
        },
        splitLine: {
          show: false
        }
      },
      tooltip: {
        formatter({ value }) {
          if (!value[0]) {
            return
          }
          return `${value[2]}<br/>${param.xAxis.name}: ${value[0]}%<br/>${param.yAxis.name}: ${value[1]}'%'`
        },
        axisPointer: {
          show: true,
          type: 'cross',
          lineStyle: {
            type: 'dashed',
            width: 1
          }
        }
      },
      series: setSeries(
        { series: param.series },
        {
          yAxis: param.yAxis.max - (param.yAxis.max - param.yAxis.min) / 2,
          xAxis: param.xAxis.max - (param.xAxis.max - param.xAxis.min) / 2
        }
      )
    })
  }
}
